﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="RelationshipsDataType.cs" company="Vizioz Limited">
//   Open Source - MIT License 2011
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace Vizioz.Relationships
{
    using System;

    using umbraco.cms.businesslogic.datatype;
    using umbraco.interfaces;

    /// <summary>
    /// The relationships data type.
    /// </summary>
    public class RelationshipsDataType : BaseDataType, IDataType
    {
        #region Constants and Fields

        /// <summary>
        /// The _ editor.
        /// </summary>
        private IDataEditor editor;

        /// <summary>
        /// The _base data.
        /// </summary>
        private IData baseData;

        /// <summary>
        /// The prevalueEditor.
        /// </summary>
        private RelationshipsPrevalueEditor prevalueEditor;

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets Data.
        /// </summary>
        public override IData Data
        {
            get
            {
                return this.baseData ?? (this.baseData = new DefaultData(this));
            }
        }

        /// <summary>
        /// Gets DataEditor.
        /// </summary>
        public override IDataEditor DataEditor
        {
            get
            {
                return this.editor
                       ??
                       (this.editor =
                        new RelationshipsDataEditor(
                            this.Data, ((RelationshipsPrevalueEditor)this.PrevalueEditor).Configuration));
            }
        }

        /// <summary>
        /// Gets DataTypeName.
        /// </summary>
        public override string DataTypeName
        {
            get
            {
                return "Vizioz Relationships";
            }
        }

        /// <summary>
        /// Gets Id.
        /// </summary>
        public override Guid Id
        {
            get
            {
                return new Guid("96270E6E-57BB-4242-BFA0-9F4A376C6BA6");
            }
        }

        /// <summary>
        /// Gets PrevalueEditor.
        /// </summary>
        public override IDataPrevalue PrevalueEditor
        {
            get
            {
                return this.prevalueEditor ?? (this.prevalueEditor = new RelationshipsPrevalueEditor(this));
            }
        }

        #endregion
    }
}